# -*- coding: utf-8 -*-

import time
from report import report_sxw
import pooler
from osv import osv
from tools.translate import _
import random
from datetime import datetime
import logging
        
class Parser(report_sxw.rml_parse):
    logging.getLoggerClass()
        
    def __init__(self, cr, uid, name, context):
        
        super(Parser, self).__init__(cr, uid, name, context=context)
        pool = pooler.get_pool(cr.dbname)
        self.pt_obj = pool.get('ctsv.phongtrao')
        
        self.localcontext.update({
            'init': self._init,
            'lines': self.get_lines,
            'pt_name': self.get_pt_name,
        })
    
    def _init(self, phongtrao):
        logging.info('----PhongTrao ID : %s', phongtrao.id)
        self.lines = self.pt_obj.get_all_lines(self.cr, self.uid, phongtrao.id)
        logging.info('----LINE SIZE: %s', len(self.lines))
        pt = self.pt_obj.browse(self.cr, self.uid, phongtrao.id, context=False)
        self.pt_name = pt.name
        logging.info('----PhongTrao: %s', self.pt_name)
        return True

    def get_lines(self):
        return self.lines
    
    def get_pt_name(self):
        return self.pt_name
    
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
